package com.tjsinfo.tjsoa.address.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.address.personal.TAddresslistPersonal;
import com.tjsinfo.tjsoa.address.personal.TAddresslistPersonalManager;
import com.tjsinfo.tjsoa.system.vo.User;

public class PersonalListAction extends Action {
	TAddresslistPersonalManager addresslistPersonalManager;
	
	public TAddresslistPersonalManager getAddresslistPersonalManager() {
		return addresslistPersonalManager;
	}

	public void setAddresslistPersonalManager(
			TAddresslistPersonalManager addresslistPersonalManager) {
		this.addresslistPersonalManager = addresslistPersonalManager;
	}

	@SuppressWarnings("unchecked")
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		try {
			HttpSession session=request.getSession();
			User tsui=(User)session.getAttribute("user");

			TAddresslistPersonal tap=new TAddresslistPersonal();
			tap.setUserId(String.valueOf(tsui.getUser_id()));
			List<TAddresslistPersonal> personal=addresslistPersonalManager.findByProperty("userId", String.valueOf(tsui.getUser_id()));
			request.setAttribute("personal", personal);
            		
			
			return mapping.findForward("success");
		} catch (Exception e) {
			e.printStackTrace();
			
			return mapping.findForward("failed");
		}
	}
}
